package com.andnnl.xiaoshuo;

import java.io.*;

/**
 * Created by chenss on 2019/12/18.
 */
public class XiaoShuoNum {
    public static void main(String[] args) {
        try {
            FileReader fr = new FileReader("C:\\Users\\andnn\\Desktop\\超级恶人重生都市2.txt");
            FileWriter fw = new FileWriter("C:\\Users\\andnn\\Desktop\\超级恶人重生都市.txt");
            BufferedReader bf = new BufferedReader(fr);
            BufferedWriter bw = new BufferedWriter(fw);
            String str;
            int i=1;
            // 按行读取字符串
            while ((str = bf.readLine()) != null) {
//                System.out.println(str);
                if(str.indexOf("xxxxx")!=-1){
                    str=str.replace("xxxxx",""+i++);
                    bw.write(str);
                    bw.newLine();
                }else{
                    bw.write(str);
                    bw.newLine();
                }
            }
            bf.close();
            fr.close();
            bw.close();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
